<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%--<%@ taglib prefix="s" uri="/struts-tags" %>--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <meta name="description" content=""/>
    <meta name="author" content=""/>
    <title>Fobia - Bootstrap 4 Web Application UI Kit</title>
    <!--favicon-->
    <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="assets/plugins/summernote/dist/summernote-bs4.css"/>
    <!-- simplebar CSS-->
    <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet"/>
    <!-- Bootstrap core CSS-->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
    <!-- animate CSS-->
    <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
    <!-- Icons CSS-->
    <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
    <!-- Sidebar CSS-->
    <link href="assets/css/sidebar-menu.css" rel="stylesheet"/>
    <!-- Custom Style-->
    <link href="assets/css/app-style.css" rel="stylesheet"/>

</head>
<body>

<div class="container-fluid" id="container-fluid">

    <div class="row pt-2 pb-2">
        <div class="col-sm-9">
            <h4 class="page-title">任务组员管理</h4>
        </div>
        <div class="col-sm-3">
            <div class="btn-group float-sm-right" style="margin-right: 40px;">
                <a href="javascript:OpPro(${tid })">
                    <button type="button" class="btn btn-success waves-effect waves-light btn-sm">添加组员</button>
                </a>
            </div>
            <div class="btn-group float-sm-right" style="margin-right: 40px;">
                <a href="javascript:Ck(${tid})">
                    <button type="button" class="btn btn-info waves-effect waves-light btn-sm">查看内容</button>
                </a>
            </div>
        </div>
    </div>
    <br/>
    <!-- End Breadcrumb-->

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header text-uppercase">任务成果表</div>
                <div class="card-body">
                    <table class="table">
                        <thead>
                        <tr>
                            <th style="width:14%">小组名</th>
                            <th>组员</th>
                            <th>是否提交</th>
                            <th>附件信息</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${list}" var="task">
                            <tr>
                                <td class="middle-align">${task.group.groupId}</td>
                                <td class="middle-align">
                                        ${task.group.stno1}&nbsp;&nbsp;
                                        ${task.group.stno2}&nbsp;&nbsp;
                                        ${task.group.stno3}&nbsp;&nbsp;
                                </td>
                                <td class="middle-align">${task.str}</td>
                                <td class="middle-align"><a href="./upload/${task.attachment}" download="${task.attachment}"><button type="button" class="btn btn-info btn-sm">下载</button></a></td>
                                <td>
                                    <button type="button" class="btn btn-warning waves-effect waves btn-sm"
                                            style="margin: 0px auto;" onclick="sweet('${task.group.groupId}')">删除
                                    </button>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div><!--End Row-->

</div>
<!-- End container-fluid-->


</body>
<!-- Bootstrap core JavaScript-->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<!-- simplebar js -->
<script src="assets/plugins/simplebar/js/simplebar.js"></script>
<!-- sidebar-menu js -->
<script src="assets/js/sidebar-menu.js"></script>

<!-- Custom scripts -->
<script src="assets/js/app-script.js"></script>

<script src="assets/plugins/summernote/dist/summernote-bs4.min.js"></script>
<script src="assets/plugins/alerts-boxes/js/sweetalert.min.js"></script>
<script src="assets/plugins/alerts-boxes/js/sweet-alert-script.js"></script>
<script>
    $('#summernoteEditor').summernote({
        height: 400,
        tabsize: 2
    });
    function sweet(data) {
        swal({
            title: "您确定吗?",			//弹出标题
            text: "该操作会删除该分组信息!",			//弹出文本
            icon: "info",				//警告图标   还有success error  info  不填就是不显示，默认不显示
            buttons: true,
            dangerMode: true,
        })
            .then((willDelete) => {
                if (willDelete) {
                    console.log(data)
                    swal("你的分组已删除!", {
                        icon: "success",
                    });
                    console.log("1")
                    $.ajax({
                        url: "delGroup?groupId=" + data,
                        dataType: 'json',
                        type: "get",

                        error: function (res) {
                           console.log("er",res)
                        },
                        success:function(res){
                            window.location.href="./listTask"
                            console.log("su",res)
                        }
                    })


                    //嵌成果方法
                } else {
                    swal("文件删除失败!");
                    //嵌失败方法
                }
            });
    }
</script>
<script>
    function OpPro(id) {
//		var id = document.getElementById("went_1").parent().attr("id");
//	var id = document.getElementById("id");
        document.getElementById("container-fluid").innerHTML +=
            "<div	id='" + id + "' class='swal-overlay swal-overlay--show-modal' tabindex='-1' style='display:block;' onclick ='CkPro(" + id + ")'>\n" +
            "	<div class='swal-text' style=' width: 50%;' onClick='event.cancelBubble = true'>\n" +
            "		<div class='wrapper'>\n" +
            "			<div class='container-fluid'>\n" +
            "				<h4 class='page-title'>请添加该任务分组成员</h4>\n" +
            "				<hr />\n" +
            "				<div class='card mt-3 shadow-none'>\n" +
            "					<div class='card-body'>\n" +
            "						<form action='addGroup' method='post'>\n"  +
            "							<input  type='hidden' name='CTask.taskId' value='" + id + "'>" +
            "							<div class='form-group'>\n" +
            "								<p style='color: #000000;'>请选择组长 &nbsp;：\n" +
            "									<select id = 'stno1' name='stno1' class='btn btn-info waves-effect waves-light btn-sm'>\n" +
            "										<optgroup label='请选择姓名'>\n" +
            "											<option value=null> </option>\n" +
            "										</optgroup>\n" +
            "									</select>\n" +
            "								</p><br>\n" +
            "								<p style='color: #000000;'>请选择组员1：\n" +
            "									<select id = 'stno2' name='stno2' class='btn btn-info waves-effect waves-light btn-sm'>\n" +
            "										<optgroup label='请选择姓名'>\n" +
            "											<option value=null> </option>\n" +
            "										</optgroup>\n" +
            "									</select>\n" +
            "								</p><br>\n" +
            "								<p style='color: #000000;'>请选择组员2：\n" +
            "									<select id = 'stno3' name='stno3' class='btn btn-info waves-effect waves-light btn-sm'>\n" +
            "										<optgroup label='请选择姓名'>\n" +
            "											<option value=null> </option>\n" +
            "										</optgroup>\n" +
            "									</select>\n" +
            "								</p><br>\n" +
            "							</div>\n" +
            "								<div class='form-group'>\n" +
            "									<label  class='btn btn-primary waves-effect waves-light m-1' for = 'submit'> 保存\n" +
            "										<input  type='submit'  style='display: none;' id = 'submit' value='保存'/>\n" +
            "										<i class='fa fa-floppy-o mr-1'></i>\n" +
            "									</label>\n" +
            "									<label  class='btn btn-danger waves-effect waves-light m-1' onclick ='ClPro(" + id + ")' for = 'reset'> 重置\n" +
            "										<input  type='reset' style='display: none;' id='reset' value='重置'>\n" +
            "										<i class='fa fa-trash-o mr-1'></i>\n" +
            "									</label>\n" +
            "								</div>\n" +
            "						</from>\n" +
            "					</div>\n" +
            "				</div>\n" +
            "			</div>\n" +
            "		</div>\n" +
            "	</div>\n" +
            "</div>\n";
        StuName();
    }

    function Ck(id) {

        $.ajax({
            url: 'finTaskJson',
            dataType: 'json',
            type: "post",
            data:{
                taskId:id
            },
            error: function () {
                alert("未收到数据");
            },
            success: function (data) {
                var name = data["tname"];
                var tS = data["startDate"];
                var tE = data["endDate"];
                var conn = data["content"];
                console.log(name)
                console.log(tS)
                console.log(tE)
                console.log(conn)

                document.getElementById("container-fluid").innerHTML +=
                    "<div	id='" + id + "' class='swal-overlay swal-overlay--show-modal' tabindex='-1' style='display:block;' onclick ='CkPro(" + id + ")'>\n" +
                    "	<div class='swal-text' style=' width: 50%; color : black'  onClick='event.cancelBubble = true'>\n" +
                    "		<div class='row'>\n" +
                    "			<div class='col-lg-12'>\n" +
                    "				<div class='card' style='width:730px;'>\n" +
                    "				<div class='card-body'>\n" +
                    "				<div class='card mt-3 shadow-none'>\n" +
                    "					<div class='card-body'>\n" +
                    "						<div class='media mb-3'>\n" +
                    //下面的是标题
                    "							<h4 class='m-0'>" + name + "</h4>\n" +
                    "							<div class='media-body'>\n" +
                    //  下面是时间，，前面的是结束时间  后面的是开始时间
                    "								<span class='media-meta float-right'>开始时间：" + tE + "</span><br><span class='media-meta float-right'>结束时间：" + tS + "</span>\n" +
                    "							</div>\n" +
                    "						</div>\n" +
                    //下面的是内容   注意去掉p标签
                    conn +
                    //内容结束
                    "						</div>\n" +
                    "					</div>\n" +
                    "				</div>\n" +
                    "			</div>\n" +
                    "			\n" +
                    "		</div>\n" +
                    "	</div>\n";

            }
        })
    }

    function CkPro(id) {
        document.getElementById(id).remove();
    }

    function StuName() {
        $.ajax({
            url: 'stulistjson',
            dataType: 'json',
            type: "post",
            error: function () {
                alert("1234");
            },
            success: function (data) {
                var course = data["stu"];
                console.log("course.length:" + course.length)
                for (var aa = 0; aa < course.length; aa++) {
                    var sid = course[aa]["sid"];
                    console.log("sid:" + sid);
                    var sname = course[aa]["sname"];
                    console.log("sname:" + sname);
                    document.getElementById("stno1").innerHTML +=
                        "<option value='" + sid + "'>" + sname + "</option>";
                    document.getElementById("stno2").innerHTML +=
                        "<option value='" + sid + "'>" + sname + "</option>";
                    document.getElementById("stno3").innerHTML +=
                        "<option value='" + sid + "'>" + sname + "</option>";
                }
            }
        })
    }
</script>
</html>
